<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!--新增入库弹窗 start-->
<div class="content-layerbody-main" id="add">
    <form name="credentialForm" id="credentialForm">
        <div class="finan-panel">
            <div class="finan-tit">
                <b>证书信息</b>
            </div>
            <div class="panel-table">
                <table class="layui-table table-info">
                    <tbody>
                    <tr>
                        <th><span class="required">证书类型</span></th>
                        <td>
                            <select class="table-select" name="certificateType" id="certificateType" onchange="loadCertificateType('100%','#certificateType','${generalType}',1,'#certificateSpecialtys',0,'#certificateLevel')">
                                <option value=''>请选择</option>
                            </select>
                        </td>
                        <th>
                            <span class="required">证书专业</span>
                        </th>
                        <td>
                            <select class="table-select" name="certificateSpecialtys" multiple="multiple" id="certificateSpecialtys" onchange="checkCertificateSpecialty('#certificateType','#certificateSpecialtys')">
                                <option value="">请先选择证书类型</option>
                            </select>
                        </td>
                        <th>
                            <span id="promptCertificateMajor" style="float: left;color: red" onclick="promptCertificateMajor()">注意!</span>
                            <span class="required">证书级别</span></th>
                        <td>
                            <select class="table-select" name="certificateLevel" id="certificateLevel">
                                <option value="">请先选择证书类型</option>
                            </select>
                        </td>
                        <th><span class="required">地区</span></th>
                        <td>
                            <div class="bus-plugIn" id="certificateArea">
                                <input type="hidden" name="certificateAreaId" class="plug-in-msg"/>
                                <input type="hidden" name="certificateArea" class="plug-in-code"/>
                                <input type="text" readonly placeholder="请选择" class="chose-plugIn layui-input" name="areaName">
                                <div class="bus-picker">
                                    <div class="bus-picker-tab">
                                        <a href="javascript:void(0);" class="active">请选择</a>
                                    </div>
                                    <div class="bus-picker-content"></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="required">证书编号</span></th>
                        <td>
                            <input type="text" class="table-input" name="certificateNo" id="certificateNo" maxlength="200" onblur="checkCertificateNo(this,'GENERAL_CREDENTIAL','${ceretificateId}',1)">
                        </td>
                        <th><span class="required">适用范围</span></th>
                        <td>
                            <select class="table-select" name="applicationScope" id="applicationScopes">
                                <c:forEach var="p" items="${applicationScopes}">
                                    <option value="${p.code}">${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th>证书过期时间</th>
                        <td>
                            <input type="text" class="table-input Wdate" name="certificateExpiryTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})">
                        </td>
                        <th><span class="required">合同签订时间</span></th>
                        <td>
                            <input type="text" class="table-input Wdate" name="contractSigningTimes" id="contractSigningTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})">
                        </td>

                    </tr>
                    <tr>
                        <th>三类证书</th>
                        <td>
                            <select class="table-select" name="certificateToThree">
                                <option value="">请选择</option>
                                <c:forEach var="p" items="${certificateToThrees}">
                                    <option value="${p.code}">${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th>三类证书到期时间</th>
                        <td>
                            <input type="text" class="table-input Wdate" name="certificateToThreeTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})">
                        </td>
                        <th><span class="required">回收价格</span></th>
                        <td>
                            <label class="input-unit">
                                <input type="text" class="table-input" name="receiptPrice" id="receiptPrice" maxlength="200">
                                <span class="unit">元</span>
                            </label>
                        </td>
                        <th>证书总价</th>
                        <td>
                            <label class="input-unit">
                                <input type="text" class="table-input" placeholder="挂出价格" name="certificatePrice" disabled maxlength="200">
                                <span class="unit">元</span>
                            </label>
                        </td>
                    </tr>
                    <tr>
                        <th>类别</th>
                        <td>
                            <select class="table-select" name="certificateCategory">
                                <option value="">请选择</option>
                                <c:forEach var="p" items="${certificateCategorys}">
                                    <option value="${p.code}">${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th><span class="required">证书名称</span></th>
                        <td>
                            <input type="text" class="table-input" name="certificateName" id="certificateName" maxlength="200">
                        </td>
                        <th><span class="required">是否买社保</span></th>
                        <td>
                            <select class="table-select" id="socialSecurity" name="socialSecurity" onchange="showSocialSecurityArea()">
                                <option value="">请选择</option>
                                <c:forEach var="p" items="${socialSecurity}">
                                    <option value="${p.code}">${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th><span name="isSocialSecurity" style="display: none;color:red;">*</span>社保区域</th>
                        <td>
                            <div id="divSocialSecurityArea" class="layui-input-inline" style="display: none">
                                <div class="bus-plugIn" id="socialSecurityArea">
                                    <input type="hidden" name="socialSecurityAreaId" class="plug-in-msg"/>
                                    <input type="hidden" name="socialSecurityArea" class="plug-in-code"/>
                                    <input type="text" readonly placeholder="请选择" class="chose-plugIn layui-input" id="socialSecurityAreaChange" name="socialSecurityAreaChange">
                                    <div class="bus-picker">
                                        <div class="bus-picker-tab">
                                            <a href="javascript:void(0);" class="active">请选择</a>
                                        </div>
                                        <div class="bus-picker-content"></div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="required">人才原件是否配合</span></th>
                        <td>
                            <select class="table-select" name="isTalentOriginalCopyCoordinate" id="isTalentOriginalCopyCoordinate">
                                <option value="">请选择</option>
                                <c:forEach var="p" items="${socialSecurity}">
                                    <option value="${p.code}">${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th><span class="required">人才出场是否配合</span></th>
                        <td>
                            <select class="table-select" name="isTalentAppearanceCoordinate" id="isTalentAppearanceCoordinate">
                                <option value="">请选择</option>
                                <c:forEach var="p" items="${socialSecurity}">
                                    <option value="${p.code}">${p.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th>特殊备注</th>
                        <td>
                            <input type="text" class="table-input" name="specialNote" id="specialNote" maxlength="30">
                        </td>

                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="finan-panel">
            <div class="finan-tit">
                <b>收证信息</b>
            </div>
            <div class="panel-table">
                <table class="layui-table table-info">
                    <tbody>
                    <tr>
                        <th>收证商务</th>
                        <td>
                            <input type="text" class="table-input" name="collectorName" value="${products.signUserName}" readonly>
                            <input type="hidden" class="table-input" name="collectorId" value="${products.signUserId}">
                        </td>
                        <th>合同编号</th>
                        <td>
                            <input type="text" class="table-input" name="contractNo" value="${products.contractNo}" readonly>
                        </td>
                        <th><span class="required">是否代签</span></th>
                        <td>
                            <select class="table-select" name="isWhetherSign" id="isWhetherSign">
                                <option value="0">是</option>
                                <option value="1">否</option>
                            </select>
                        </td>
                        <th>证书录入时间</th>
                        <td>
                            <!-- 新增证书默认录入时间为当前时间 -->
                            <input type="text" class="table-input" name="certificateEntryTimes" value="${date}" autocomplete="off" readonly>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="red">*</span>持证人姓名</th>
                        <td>
                            <input type="text" class="table-input" name="personalName" id="personalName" maxlength="200">
                        </td>
                        <th>身份证号码</th>
                        <td>
                            <input type="text" class="table-input" name="personalIdCard" id="personalIdCard" maxlength="200">
                        </td>
                        <th><span class="red">*</span>联系电话</th>
                        <td>
                            <input type="text" class="table-input" name="personalPhone" id="personalPhone" maxlength="200">
                        </td>
                        <th>微信号码</th>
                        <td>
                            <input type="text" class="table-input" name="personalWeixin" id="personalWeixin" maxlength="200">
                        </td>
                    </tr>
                    <tr>
                        <th><span class="red">*</span>收款户名</th>
                        <td>
                            <input type="text" class="table-input" name="accountName" id="accountName" maxlength="200">
                        </td>
                        <th><span class="red">*</span>收款账号</th>
                        <td>
                            <input type="text" class="table-input" name="accountNo" id="accountNo" maxlength="200">
                        </td>
                        <th><span class="red">*</span>开户行</th>
                        <td>
                            <input type="text" class="table-input" name="accountBank" id="accountBank" maxlength="200">
                        </td>
                        <th>定金（元）</th>
                        <td>
                            <label class="input-unit">
                                <input type="text" class="table-input" name="deposit" value="${products.theDeposit}" readonly maxlength="200">
                                <span class="unit">元</span>
                            </label>
                        </td>
                    </tr>

                    <tr>
                        <th><span class="required">人才付款方式</span></th>
                        <td>
                            <select class="table-select" name="talentPaymentMethod" id="talentPaymentMethod">
                                <option value="">请选择</option>
                                <option value="0">签付</option>
                                <option value="1">使用后付款</option>
                            </select>
                        </td>
                        <th><span class="required">收证类型</span></th>
                        <td>
                            <select class="select-style" name="receiptType" onchange="receiptType1()">
                                <option value="">请选择</option>
                                <option value="0">渠道收证</option>
                                <option value="1">人才收证</option>
                            </select>
                        </td>
                        <th><span name="receiptType" style="display: none;color:red;">*</span>渠道名称</th>
                        <td>
                            <input readonly type="text" class="table-input" name="channelName" id="channelName" maxlength="200" placeholder="请输入渠道名称">
                        </td>
                        <th><span name="receiptType" style="display: none;color:red;">*</span>渠道电话</th>
                        <td>
                            <input readonly onkeyup="this.value=this.value.replace(/\D/g,'')" type="text" class="table-input" name="channelPhone" id="channelPhone" maxlength="11" placeholder="请输入渠道电话">
                        </td>
                    </tr>

                    <tr>
                        <th><span name="receiptType" style="display: none;color:red;">*</span>渠道身份证号</th>
                        <td>
                            <input readonly type="text" class="table-input" name="channelIdCard" id="channelIdCard" placeholder="请输入渠道身份证">
                        </td>
                        <th>定金支付时间</th>
                        <td>
                            <input type="text" class="table-input" name="depositPayTimes" autocomplete="off" value="<fmt:formatDate value="${products.theDepositTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly>
                        </td>
                        <th>尾款</th>
                        <td>
                            <label class="input-unit">
                                <input type="text" class="table-input" name="tailMoney" value="${products.balancePayment}" readonly>
                                <span class="unit">元</span>
                            </label>
                        </td>
                        <th>尾款支付时间</th>
                        <td>
                            <input type="text" class="table-input" name="tailMoneyPayTimes" autocomplete="off" value="<fmt:formatDate value="${products.balancePaymentTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="red">*</span>是否有资格证书</th>
                        <td>
                            <select class="table-select" name="isQuelificationCertificate" id="isQuelificationCertificate">
                                <option value="0">是</option>
                                <option value="1">否</option>
                            </select>
                        </td>
                        <th><span class="red">*</span>是否有毕业证书</th>
                        <td>
                            <select class="table-select" name="isGraduationCertificate" id="isGraduationCertificate">
                                <option value="0">是</option>
                                <option value="1">否</option>
                            </select>
                        </td>
                            <%--<th><span class="red">*</span>是否有信息卡</th>--%>
                            <%--<td>--%>
                                <%--<select class="table-select" name="isInformationCard" id="isInformationCard">--%>
                                    <%--<option value="0">是</option>--%>
                                    <%--<option value="1">否</option>--%>
                                <%--</select>--%>
                            <%--</td>--%>
                        <th><span class="red">*</span>是否集团归档</th>
                        <td>
                            <select class="table-select" name="isGroupFiling" id="isGroupFiling">
                                <option value="0">是</option>
                                <option value="1">否</option>
                            </select>
                        </td>
                        <th></th>
                        <td></td>

                        <td>
                            <!-- 基础证书id -->
                            <input type="hidden" name="id" id="id" value="${ceretificateId}">
                            <!-- 生产订单id -->
                            <input type="hidden" name="scOrderId" id="scOrderId" value="${products.scProductOrderId}">
                            <input type="hidden" name="scOrderNo" id="scOrderNo" value="${products.scProductOrderNo}">
                            <!-- 销售子订单id -->
                            <input type="hidden" name="productId" id="productId" value="${products.id}">
                            <!-- 签单事业部 -->
                            <input type="hidden" name="signOrgId" id="signOrgId" value="${products.productOrgId}">
                            <input type="hidden" name="signOrgName" id="signOrgName" value="${products.productOrgName}">
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="finan-panel">
            <div class="finan-tit">
                <b>证书状态</b>
            </div>
            <div class="panel-table">
                <table class="layui-table table-info">
                    <tbody>
                    <tr>
                        <th>证书状态</th>
                        <td>
                            <!-- 新增证书默认在库状态为出库 -->
                            <input type="text" class="table-input" value="未使用" disabled>
                            <input type="hidden" name="certificateStatus" value="GENERAL_CREDENTIAL_STATUS_01">
                        </td>
                        <th>在库状态</th>
                        <td>
                            <!-- 新增证书默认出入库状态为在库 -->
                            <input type="text" class="table-input" value="在库" disabled>
                            <input type="hidden" name="libraryStatus" value="GENERAL_CERTIFICATE_LIBRARY_STATUS_01">
                        </td>
                        <th>最新入库时间</th>
                        <td>
                            <input type="text" class="table-input" name="lastWarehousingTimes" autocomplete="off" placeholder="最新入库时间" value="${date}" disabled>
                        </td>
                        <th>最新出库时间</th>
                        <td>
                            <input type="text" class="table-input" name="lastOutgoingTimes" readonly placeholder="最新出库时间">
                        </td>
                    </tr>
                    <tr>
                        <th>人才合同到期时间</th>
                        <td>
                            <input type="text" class="table-input Wdate" name="talentContractExpireTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})">
                        </td>
                        <th>企业合同到期时间</th>
                        <td>
                            <input type="text" class="table-input Wdate" maxlength="200" name="companyContractExpireTimes" autocomplete="off" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})">
                        </td>
                        <th>使用公司</th>
                        <td>
                            <input type="text" class="table-input" name="affiliatedCompany" disabled placeholder="使用公司" maxlength="200">
                        </td>
                        <th>使用起始时间</th>
                        <td>
                            <input type="text" class="table-input" name="affiliatedStartTimes" autocomplete="off" placeholder="使用起始时间" disabled>
                        </td>
                    </tr>
                    <tr>
                        <th>使用到期时间</th>
                        <td>
                            <input type="text" class="table-input" name="affiliatedExpireTimes" autocomplete="off" placeholder="使用到期时间" disabled>
                        </td>
                        <th>三类使用公司</th>
                        <td>
                            <input type="text" class="table-input" name="threeAffiliatedCompany" placeholder="三类使用公司" disabled maxlength="200">
                        </td>
                        <th>三类使用起始时间</th>
                        <td>
                            <input type="text" class="table-input" name="threeAffiliatedStartTimes" autocomplete="off" placeholder="三类使用起始时间" disabled>
                        </td>
                        <th>三类使用到期时间</th>
                        <td>
                            <input type="text" class="table-input" name="threeAffiliatedExpireTimes" autocomplete="off" placeholder="三类使用到期时间" disabled>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="finan-panel">
            <div class="finan-tit">
                <b>附件信息</b>
            </div>
            <div class="panel-main">
                <ul class="data-warp">
                    <li style="width: 100px;">证书附件</li>
                    <li>
                        <a href="javascript:void(0)" class="upload-button" id="upload"></a>
                        <input class="layui-upload-file" type="file" name="file" multiple="" id="annexUpload" data-type="credential" data-fileid="${ceretificateId}">
                        <p>上传附件</p>
                    </li>
                </ul>
                <ul class="data-warp">
                    <li style="width: 100px;">证书使用附件</li>
                    <li>
                        <a href="javascript:void(0)" class="upload-button" id="upload1"></a>
                        <input class="layui-upload-file" type="file" name="file" multiple="" id="annexUpload1" data-type="attachmentForCertificate" data-fileid="${ceretificateId}">
                        <p>上传附件</p>
                    </li>
                </ul>
                <ul class="data-warp">
                    <li style="width: 100px;">财务付款附件</li>
                    <li>
                        <a href="javascript:void(0)" class="upload-button" id="upload2"></a>
                        <input class="layui-upload-file" type="file" name="file" multiple="" id="annexUpload2" data-type="financialPaymentAttachment" data-fileid="${ceretificateId}">
                        <p>上传附件</p>
                    </li>
                </ul>
            </div>
        </div>
    </form>
</div>

<script src="${rootUrl}/static/js/zzsc/common/files/annex.js?v=${version}" type="text/javascript" charset="utf-8"></script>
<!--新增入库弹窗 end-->
<script>
    $(function () {
        /**
         * 资质类型、证书专业以及证书级别三级联动判断
         * @param obj 证书类型
         * @param generalType 大类型(证书或资质)编码
         * @param type 联动类型  0-查询证书类型 1-根据证书类型查询证书专业  2-不加载证书级别
         * @param isLoadLevel 是否加载证书级别 0-加载 1-不加载
         * @param certificateSpecialtyObj 证书专业
         * @param certificateLevelObj 证书级别
         */
        loadCertificateType('100%', '#certificateType', '${generalType}', 0);

        //异步加载
        Plug.plug_ins(
            "get",
            "${cmsBaseUrl}/api/cms/tree_book/v1/get_tree_book_list.do?code=2147483647&type=2&level=1",
            "#certificateArea",
            '请选择地区',
            function () {
            },
            true, '2147483647'
        );
        //异步加载
        Plug.plug_ins(
            "get",
            "${cmsBaseUrl}/api/cms/tree_book/v1/get_tree_book_list.do?code=2147483647&type=2&level=1",
            "#socialSecurityArea",
            '请选择地区',
            function () {
            },
            true, '2147483647'
        );

        // $('#certificateSpecialtys').select2({
        //     placeholder: "请选择",
        //     allowClear: true,
        //     width: "190px",
        //     language: "zh-CN"
        // });
        //
        // $('#certificateLevel').select2({
        //     placeholder: "请选择",
        //     allowClear: true,
        //     width: "190px",
        //     language: "zh-CN"
        // });
    })
    function promptCertificateMajor() {
        DGG.Tip("注意：系统匹配证书时将按照证专业选择的顺序进行匹配",$('#promptCertificateMajor'),{tips: [3, '#000'], time: 3000});
    }

</script>